import fetcher from "./Fetcher";
import {YearMonth} from "@js-joda/core";

export interface MarketStatisticRequest{
    brandIds?:Array<number>
    startYearMonth?:YearMonth
    endYearMonth?:YearMonth
}

export function getMarketStatistic(id:number,request:MarketStatisticRequest = {}){
    return fetcher.get<MarketStatisticResponse>(`markets/${id}/statistics`,request)
}

export interface MarketStatisticResponse{
    /**
     * 总送货零售价
     */
     totalPrice:number,
    /**
     * 总成本
     */
     totalCost:number,
    /**
     * 送货单数量
     */
     deliveryOrderCount:number,
    /**
     * 总销售额
     */
     totalSoled:number,
}

export function getMarketSoldEveryMonthStatistic(id:number,request:MarketStatisticRequest){
    return fetcher.get<MarketSoldEveryMonthStatisticResponse>(`markets/${id}/statistics/soldGroupByMonth`)
}

export interface MarketSoldEveryMonthStatisticResponse{
    yearMonthData:MarketSoldEveryMonthStatisticYearMonthData[]
}

export interface MarketSoldEveryMonthStatisticYearMonthData{
    statisticYearMonth:YearMonth
    totalSoled:number
}